package com.simple.gateway.center.domian.application.bo;

import com.simple.gateway.center.basedata.po.ApplicationSystem;
import com.simple.gateway.center.domian.application.dto.ApplicationSystemDTO;
import com.simple.gateway.center.domian.application.param.ApplicationSystemParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 项目: simple-gateway-core
 *
 * 功能描述:
 *
 * @author: WuChengXing
 *
 * @create: 2023-08-07 17:10
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ApplicationSystemBO {

    /**
     * 系统标识
     */
    private String systemId;
    /**
     * 系统名称
     */
    private String systemName;
    /**
     * 系统类型；RPC、HTTP
     */
    private String systemType;
    /**
     * 注册中心
     */
    private String systemRegistry;

    /**
     * 扩展字段
     */
    private String extension;

    private List<ApplicationInterfaceBO> applicationInterfaceBOS;

    public static ApplicationSystemBO param2Bo(ApplicationSystemParam applicationSystemParam) {
        return ApplicationSystemBO.builder()
                .systemId(applicationSystemParam.getSystemId())
                .systemName(applicationSystemParam.getSystemName())
                .systemType(applicationSystemParam.getSystemType())
                .systemRegistry(applicationSystemParam.getSystemRegistry())
                .extension(applicationSystemParam.getExtension())
                .build();
    }

    public static ApplicationSystemBO do2Bo(ApplicationSystem applicationSystem) {
        return ApplicationSystemBO.builder()
                .systemId(applicationSystem.getSystemId())
                .systemName(applicationSystem.getSystemName())
                .systemType(applicationSystem.getSystemType())
                .systemRegistry(applicationSystem.getSystemRegistry())
                .extension(applicationSystem.getExtension())
                .build();
    }

    public static ApplicationSystem bo2Do(ApplicationSystemBO applicationSystemBO) {
        ApplicationSystem applicationSystem = new ApplicationSystem();
        applicationSystem.setSystemId(applicationSystemBO.getSystemId());
        applicationSystem.setSystemName(applicationSystemBO.getSystemName());
        applicationSystem.setSystemType(applicationSystemBO.getSystemType());
        applicationSystem.setSystemRegistry(applicationSystemBO.getSystemRegistry());
        applicationSystem.setExtension(applicationSystemBO.getExtension());
        return applicationSystem;
    }

    public static ApplicationSystemDTO bo2Dto(ApplicationSystemBO applicationSystemBO) {
        ApplicationSystemDTO dto = new ApplicationSystemDTO();
        dto.setSystemId(applicationSystemBO.getSystemId());
        dto.setSystemName(applicationSystemBO.getSystemName());
        dto.setSystemType(applicationSystemBO.getSystemType());
        dto.setSystemRegistry(applicationSystemBO.getSystemRegistry());
        dto.setExtension(applicationSystemBO.getExtension());
        return dto;
    }
}
